package ru.ifmo.kis.domaingen;

import javax.persistence.*;

// Nov 24, 2010 4:04:22 PM
@Table(name = "materials", catalog = "ItmoKis")
@Entity
public class MaterialsEntity {
	private int id;

	@Column(name = "id", nullable = true, insertable = true, updatable = true, length = 10, precision = 0)
	@Id
	public int getId() {
		return id;
	}

	public void setId(int id) {
		this.id = id;
	}

	private String name;

	@Column(name = "name", nullable = true, insertable = true, updatable = true, length = 64, precision = 0)
	@Basic
	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	private float volume;

	@Column(name = "volume", nullable = true, insertable = true, updatable = true, length = 12, precision = 0)
	@Basic
	public float getVolume() {
		return volume;
	}

	public void setVolume(float volume) {
		this.volume = volume;
	}

	private int count;

	@Column(name = "count", nullable = true, insertable = true, updatable = true, length = 10, precision = 0)
	@Basic
	public int getCount() {
		return count;
	}

	public void setCount(int count) {
		this.count = count;
	}

	@Override
	public boolean equals(Object o) {
		if (this == o) return true;
		if (o == null || getClass() != o.getClass()) return false;

		MaterialsEntity that = (MaterialsEntity) o;

		if (count != that.count) return false;
		if (id != that.id) return false;
		if (Float.compare(that.volume, volume) != 0) return false;
		if (name != null ? !name.equals(that.name) : that.name != null) return false;

		return true;
	}

	@Override
	public int hashCode() {
		int result = id;
		result = 31 * result + (name != null ? name.hashCode() : 0);
		result = 31 * result + (volume != +0.0f ? Float.floatToIntBits(volume) : 0);
		result = 31 * result + count;
		return result;
	}
}
